package demo2;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
         int n = scan.nextInt() ;
         int[] array = new int[n+1] ; 
         int[] dp = new int[n+1] ; 
         int q = scan.nextInt() ;
         for(int i = 1 ; i < array.length ; i ++){
             int num = scan.nextInt() ;
           array[i] = num ;
            dp[i] = num + dp[i-1];
         }
        for(int i = 0 ; i < q ; i ++){
            int left = scan.nextInt() ;
            int right = scan.nextInt() ;
            int sum = dp[right]-dp[left]+array[left];
            System.out.println(sum);
        }


    }
}